package com.lg.algorithm.leetcode;

import java.util.Arrays;

public class MoveZeroes {
    public static void moveZeroes(int[] nums) {
        int zeroNum = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0) {
                zeroNum++;
                continue;
            }
            nums[i - zeroNum] = nums[i];
        }

        for (int len = nums.length; zeroNum > 0 ; zeroNum--) {
            nums[len - zeroNum] = 0;
        }
    }

    public static void main(String[] args) {
        int []nums =  {1,2,0,3,4,0,5,0,6,0};
        moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }
}
